/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package location.security;

import com.opensymphony.xwork2.ActionSupport;
import locations.dao.implement.UserDAOHibernateJPA;
import org.apache.struts2.ServletActionContext;
import org.springframework.validation.FieldError;

public class LoginValidationAction extends ActionSupport{
    private String userName;
    private String password;
    public String execute(){
        ServletActionContext.getRequest().getSession().setAttribute("usuario", "valido");
        return SUCCESS;
    }
    public void validate(){
        UserDAOHibernateJPA udaohjpa = new UserDAOHibernateJPA();
        if (! udaohjpa.existUser(userName, password))
        {
            addActionError("Usuario Invalido");
        }
        
//        if(userName.equals("admin")&&(password.equals("pass"))){
//            System.out.println("correcto llupi");
//        }else{
//            addActionError("Usuario Invalido");
//        }
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    
}
